Rough in preferences screen. Not functional yet. Has serious layout issues.
authorrobertl <robertl>
Sun, 14 Feb 2010 21:29:05 +0000 (21:29 +0000)
committerrobertl <robertl>
Sun, 14 Feb 2010 21:29:05 +0000 (21:29 +0000)
gui/app.pro
gui/mainwindow.cpp
gui/mainwindow.h
gui/mainwinui.ui
gui/preferences.cpp [new file with mode: 0644]
gui/preferences.h [new file with mode: 0644]
gui/preferences.ui [new file with mode: 0644]
gui/upgrade.cpp

index 87f7007c3645049281a422fffd83cadca163f0f6..432acd67733a34fbe2b3909fd5057bdf469a8778 100755 (executable)
@@ -1,4 +1,4 @@
-# $Id: app.pro,v 1.14 2010/01/05 15:01:30 robertl Exp $
+# $Id: app.pro,v 1.15 2010/02/14 21:29:05 robertl Exp $
 #
 
 CONFIG += qt release 
@@ -29,55 +29,58 @@ mac:TARGET=GPSBabelFE
 win32:TARGET=GPSBabelFE
 unix:TARGET=gpsbabelfe-bin
 
-FORMS += mainwinui.ui
-FORMS += advui.ui
 FORMS += aboutui.ui
-FORMS += trackui.ui
+FORMS += advui.ui
 FORMS += filterui.ui
-FORMS += wayptsui.ui
-FORMS += rttrkui.ui
-FORMS += miscfltui.ui
 FORMS += gmapui.ui
+FORMS += mainwinui.ui
+FORMS += miscfltui.ui
+FORMS += preferences.ui
+FORMS += rttrkui.ui
+FORMS += trackui.ui
 FORMS += upgrade.ui
+FORMS += wayptsui.ui
 
+SOURCES += aboutdlg.cpp
 SOURCES += advdlg.cpp
 SOURCES += dpencode.cpp
-SOURCES += map.cpp
-SOURCES += latlng.cpp
-SOURCES += gpx.cpp
+SOURCES += filterdata.cpp
+SOURCES += filterdlg.cpp
+SOURCES += filterwidgets.cpp
+SOURCES += format.cpp
+SOURCES += formatload.cpp
 SOURCES += gmapdlg.cpp
-SOURCES += aboutdlg.cpp
-SOURCES += main.cpp
+SOURCES += gpx.cpp
 SOURCES += help.cpp
+SOURCES += latlng.cpp
+SOURCES += main.cpp
 SOURCES += mainwindow.cpp
-SOURCES += format.cpp
-SOURCES += filterdata.cpp
-SOURCES += formatload.cpp
+SOURCES += map.cpp
 SOURCES += optionsdlg.cpp
+SOURCES += preferences.cpp
 SOURCES += processwait.cpp
-SOURCES += filterwidgets.cpp
-SOURCES += filterdlg.cpp
 SOURCES += upgrade.cpp
 macx:SOURCES += serial_mac.cpp
 unix:SOURCES += serial_unix.cpp
 windows:SOURCES += serial_win.cpp
 
-HEADERS += mainwindow.h
-HEADERS += map.h
-HEADERS += gmapdlg.h
-HEADERS += gpx.h
+HEADERS += aboutdlg.h
+HEADERS += advdlg.h
+HEADERS += appname.h
 HEADERS += babeldata.h
+HEADERS += filterdata.h
 HEADERS += filterdlg.h
-HEADERS += appname.h
-HEADERS += advdlg.h
-HEADERS += aboutdlg.h
-HEADERS += help.h
+HEADERS += filterwidgets.h
 HEADERS += format.h
 HEADERS += formatload.h
+HEADERS += gmapdlg.h
+HEADERS += gpx.h
+HEADERS += help.h
+HEADERS += mainwindow.h
+HEADERS += map.h
 HEADERS += optionsdlg.h
+HEADERS += preferences.h
 HEADERS += processwait.h
-HEADERS += filterwidgets.h
-HEADERS += filterdata.h
 HEADERS += setting.h
 HEADERS += upgrade.h
 
index f09bc5d63ba4baaf17e0a704666d0c8488caa403..dc8d0a9b7b14bbbd8d830c1971ce5d569870b9aa 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: mainwindow.cpp,v 1.14 2010/02/14 05:33:37 robertl Exp $
+// $Id: mainwindow.cpp,v 1.15 2010/02/14 21:29:06 robertl Exp $
 //------------------------------------------------------------------------
 //
 //  Copyright (C) 2009  S. Khai Mong <khai@mangrai.com>.
 #include <QTemporaryFile>
 
 #include "mainwindow.h"
-#include "babeldata.h"
-#include "appname.h"
-#include "help.h"
-#include "advdlg.h"
 #include "aboutdlg.h"
-#include "optionsdlg.h"
+#include "advdlg.h"
+#include "appname.h"
+#include "babeldata.h"
 #include "filterdlg.h"
-#include "processwait.h"
 #include "formatload.h"
 #include "gmapdlg.h"
+#include "help.h"
+#include "optionsdlg.h"
+#include "preferences.h"
+#include "processwait.h"
 #include "upgrade.h"
 #include "../gbversion.h"
 
@@ -131,6 +132,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent)
   connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(closeActionX()));
   connect(ui.actionHelp, SIGNAL(triggered()), this, SLOT(helpActionX()));
   connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(aboutActionX()));
+  connect(ui.actionPreferences, SIGNAL(triggered()), this, SLOT(preferencesActionX()));
 
   connect(ui.inputFormatCombo,  SIGNAL(currentIndexChanged(int)),
          this,                 SLOT(inputFormatChanged(int)));
@@ -960,6 +962,14 @@ void MainWindow::aboutActionX()
   aboutDlg.exec();
 }
 
+//------------------------------------------------------------------------
+void MainWindow::preferencesActionX()
+{
+  Preferences preferences(0, formatList);
+  preferences.exec();
+}
+
+
 //------------------------------------------------------------------------
 void MainWindow::helpActionX()
 {
index 49bab36f2fd5c690af22f860db91111e1fe0d97f..09d7713da4e71d5b267b835af8a7771ff78c7053 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: mainwindow.h,v 1.7 2009/09/15 18:04:03 robertl Exp $
+// $Id: mainwindow.h,v 1.8 2010/02/14 21:29:06 robertl Exp $
 //------------------------------------------------------------------------
 //
 //  Copyright (C) 2009  S. Khai Mong <khai@mangrai.com>.
@@ -87,22 +87,23 @@ protected:
   void closeEvent(QCloseEvent*);
 
  private slots:
-  void inputFileOptBtnClicked();
-  void inputDeviceOptBtnClicked();
-  void inputOptionButtonClicked();
-  void inputFormatChanged(int);
+  void aboutActionX();
+  void applyActionX();
   void browseInputFile();
-  void outputFileOptBtnClicked();
-  void outputDeviceOptBtnClicked();
-  void outputOptionButtonClicked();
-  void outputFormatChanged(int);
   void browseOutputFile();
-  void moreOptionButtonClicked();
-  void applyActionX();
-  void aboutActionX();
-  void helpActionX();
   void closeActionX();
   void filtersClicked();
+  void helpActionX();
+  void inputDeviceOptBtnClicked();
+  void inputFileOptBtnClicked();
+  void inputFormatChanged(int);
+  void inputOptionButtonClicked();
+  void moreOptionButtonClicked();
+  void outputDeviceOptBtnClicked();
+  void outputFileOptBtnClicked();
+  void outputFormatChanged(int);
+  void outputOptionButtonClicked();
+  void preferencesActionX();
   void resetFormatDefaults();
 
 };
index 1e9a7ebe5cb78084ec1203e7a061c79a88878414..62b123243b394c6f014b8bf8d891ebc561768eb1 100644 (file)
     <property name="title">
      <string>File</string>
     </property>
+    <addaction name="actionPreferences"/>
     <addaction name="actionQuit"/>
    </widget>
    <widget class="QMenu" name="menuHelp">
     <string>Quit</string>
    </property>
   </action>
+  <action name="actionPreferences">
+   <property name="text">
+    <string>Preferences...</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="app.qrc"/>
diff --git a/gui/preferences.cpp b/gui/preferences.cpp
new file mode 100644 (file)
index 0000000..a5307ba
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// Copyright (C) 2010  Robert Lipe  <robertlipe@gpsbabel.org>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License as
+//  published by the Free Software Foundation; either version 2 of the
+//  License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111
+//  USA
+
+
+#include <QSettings>
+#include "preferences.h"
+
+class FormatListEntry : public QListWidgetItem {
+ public:
+  FormatListEntry(Format& fmt) : fmt_(fmt)  {
+    setText(fmt.getDescription());
+    bool enabled = !fmt.isHidden();
+    setCheckState(enabled ? Qt::Checked : Qt::Unchecked);
+  }
+
+ private:
+   Format& fmt_;
+};
+
+Preferences::Preferences(QWidget* parent, QList<Format>& formatList) :
+  formatList_(formatList)
+{
+  ui_.setupUi(this);
+
+  // TODO: read from prefs.
+  // ui_.startupCheck->setChecked(true);
+  connect (ui_.buttonBox, SIGNAL(accepted()), this, SLOT(acceptClicked()));
+  connect (ui_.buttonBox, SIGNAL(rejected()), this, SLOT(rejectClicked()));
+
+  connect (ui_.enableAllButton, SIGNAL(clicked()), this, SLOT(enableAllClicked()));
+  connect (ui_.disableAllButton, SIGNAL(clicked()), this, SLOT(disableAllClicked()));
+
+  for (int i = 0; i < formatList_.size(); i++) {
+    FormatListEntry *item = new FormatListEntry(formatList[i]);
+
+    ui_.enabledFormatsList->insertItem(0, item);
+  }
+}
+
+void Preferences::enableAllClicked()
+{
+  for (int i = 0; i < ui_.enabledFormatsList->count(); i++) {
+    QListWidgetItem* item = ui_.enabledFormatsList->item(i);
+    item->setCheckState(Qt::Checked);
+  }
+}
+
+void Preferences::disableAllClicked()
+{
+  for (int i = 0; i < ui_.enabledFormatsList->count(); i++) {
+    QListWidgetItem* item = ui_.enabledFormatsList->item(i);
+    item->setCheckState(Qt::Unchecked);
+  }
+}
+
+void Preferences::acceptClicked()
+{
+  accept();
+}
+
+void Preferences::rejectClicked()
+{
+  reject();
+}
diff --git a/gui/preferences.h b/gui/preferences.h
new file mode 100644 (file)
index 0000000..15c95aa
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef PREFERENCES_H_
+#define PREFERENCES_H_
+
+//
+// Copyright (C) 2010  Robert Lipe  <robertlipe@gpsbabel.org>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License as
+//  published by the Free Software Foundation; either version 2 of the
+//  License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111
+//  USA
+
+#include "ui_preferences.h"
+#include "format.h"
+
+class Preferences : public QDialog {
+  Q_OBJECT
+
+ public:
+  Preferences(QWidget* parent, QList<Format>& formatList);
+
+ private:
+  QList<Format>& formatList_;
+  Ui_Preferences ui_;
+
+ private slots:
+  void enableAllClicked();
+  void disableAllClicked();
+  void acceptClicked();
+  void rejectClicked();
+};
+
+#endif //  PREFERENCES_H_
diff --git a/gui/preferences.ui b/gui/preferences.ui
new file mode 100644 (file)
index 0000000..6ed3352
--- /dev/null
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Preferences</class>
+ <widget class="QDialog" name="Preferences">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>777</width>
+    <height>351</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle">
+   <string>GPSBabel Preferences</string>
+  </property>
+  <layout class="QFormLayout" name="formLayout">
+   <item row="0" column="0">
+    <widget class="QTabWidget" name="tabWidget">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="currentIndex">
+      <number>1</number>
+     </property>
+     <widget class="QWidget" name="general_tab">
+      <attribute name="title">
+       <string>General</string>
+      </attribute>
+      <widget class="QWidget" name="layoutWidget">
+       <property name="geometry">
+        <rect>
+         <x>23</x>
+         <y>18</y>
+         <width>234</width>
+         <height>43</height>
+        </rect>
+       </property>
+       <layout class="QVBoxLayout" name="verticalLayout_4">
+        <item>
+         <widget class="QCheckBox" name="startupCheck">
+          <property name="text">
+           <string>Check for newer version on start.</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="checkBox">
+          <property name="text">
+           <string>Anonymously report usage data.</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </widget>
+     <widget class="QWidget" name="format_tab">
+      <attribute name="title">
+       <string>Formats</string>
+      </attribute>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout">
+         <item>
+          <widget class="QLabel" name="label">
+           <property name="text">
+            <string>Enabled Formats</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QListWidget" name="enabledFormatsList">
+           <property name="sortingEnabled">
+            <bool>true</bool>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout_3">
+         <item>
+          <widget class="QPushButton" name="enableAllButton">
+           <property name="text">
+            <string>Enable All</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QPushButton" name="disableAllButton">
+           <property name="text">
+            <string>Disable All</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item row="1" column="0">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 5fd7b7262e22159bb4d36a59c4fcec58bcd84383..22613fd4d0d85c3e46e21d548c5a541ebe16e8cf 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: upgrade.cpp,v 1.20 2010/02/14 05:33:37 robertl Exp $
+// $Id: upgrade.cpp,v 1.21 2010/02/14 21:29:06 robertl Exp $
 /*
     Copyright (C) 2009, 2010  Robert Lipe, robertlipe@gpsbabel.org
 
@@ -120,7 +120,6 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString &currentV
   currentVersion = currentVersionIn;
   currentVersion.remove("GPSBabel Version ");
   upgradeCheckMethod = checkMethod;
-//  formatList_ = &formatList;
 
   QDateTime soonestCheckTime = lastCheckTime.addDays(1);
   if (!testing && QDateTime::currentDateTime() < soonestCheckTime) {